package com.fitnessapp.activities;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


import com.fitnessapp.main.FitnessApplication;
import com.fitnessapp.main.IntentExtras;
import com.fitnessapp.main.R;
import com.fitnessapp.main.R.array;
import com.fitnessapp.user.Routine;
import com.fitnessapp.user.User;

import android.app.ExpandableListActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.SimpleExpandableListAdapter;

public class RoutineActivity extends ExpandableListActivity {
	
	private static final String NAME = "name";
	
	private ArrayList<HashMap<String,String>> headers = new ArrayList<HashMap<String,String>>();
	private ArrayList<HashMap<String, String>> childData = new ArrayList<HashMap<String,String>>();
	
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		
	//	setContentView(R.layout.layout_expandable_list);
		
		String[] days = getResources().getStringArray(R.array.daysOfTheWeek);
		
		User currentUser = ((FitnessApplication)getApplication()).getUser();
		String routineName = getIntent().getStringExtra(IntentExtras.ROUTINE_INDEX);
		
		Routine selectedRoutine = currentUser.getRoutine(routineName);
		
		if(selectedRoutine != null){	
			//children data
			ArrayList<ArrayList<HashMap<String,String>>> childData = new ArrayList<ArrayList<HashMap<String,String>>>(days.length);
			
			//populate the days of the week in the as the title for each group
			for(int i = 0; i < days.length; i++){
				HashMap<String,String> dayOfWeek = new HashMap<String, String>();
				dayOfWeek.put(NAME, days[i]);
				
				//get exercises for that day
//				List<Exercise> exercies = selectedRoutine.getExercies(i);
//				
//				ArrayList<HashMap<String,String>> dailyExerciseData = new ArrayList<HashMap<String,String>>(exercies.size());				
//				
//				for(Exercise exercise : exercies){
//					HashMap<String, String> exerciseData = new HashMap<String,String>();
//					exerciseData.put(NAME, exercise.getName());
//					dailyExerciseData.add(exerciseData);
//				}				
				
				
				headers.add(dayOfWeek);
				//childData.add(dailyExerciseData);
			}
//			
//			setListAdapter(new SimpleExpandableListAdapter(this, headers, android.R.layout.simple_expandable_list_item_1,
//					new String[] {NAME},
//					new int[] { android.R.id.text1 },
//					childData,
//					R.layout.list_view_text_row,
//					new String[] {NAME},
//					new int[] { R.id.rowText }));
		}else{
			//routine was not found log error and display message
			Log.e(getLocalClassName(), "Selected routine was null");
		}
	}

}
